<include file="public/layout" />
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
<body style="background-color: #FFF; overflow: auto;"> 
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3> 广告详情</h3>
        <h5>广告添加与管理</h5>
      </div>
    </div>
  </div>
    <!--表单数据-->
    <form method="post" id="handleposition" action="{:U('Admin/Ad/adHandle')}">  
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label><em>*</em>广告名称：</label>
        </dt>
        <dd class="opt">
          <input type="text" placeholder="名称" class="input-txt" name="ad_name" value="{$info.ad_name|default='自定义广告名称'}">
		  <span class="err" id="err_ad_name" style="color:#F00; display:none;">广告名称不能为空</span>                                                  
          <p class="notic"></p>
        </dd>
      </dl>	   
	 

	  <dl class="row">
        <dt class="tit" colspan="2">
          <label>广告类型：</label>
        </dt>
        <dd class="opt">
          <div>
          		<select name="atype" class="input-sm" class="form-control">
	                <volist name="atype" id="item">
	                       <option value="{$item.atypeid}" <if condition="$info.atype eq $item.atypeid">selected</if>>{$item.atypename}</option>
	               </volist>                  
	            </select> 
          </div>          
        </dd>
     </dl>    
      
      <dl class="row">
        <dt class="tit">
          <label>广告图片</label>
        </dt>
        <dd class="opt">
          <div class="input-file-show">
                <span class="show">
                    <a id="img_a" target="_blank" class="nyroModal" rel="gal">
                      <i id="img_i" class="fa fa-picture-o" onmouseover="layer.tips('<img src=__PUBLICROOT__{$info.icon}>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();"></i>
                    </a>
                </span>
   	            <span class="type-file-box">
                    <input type="text" id="icon" name="icon" value="{$info.icon}" class="type-file-text">
                    <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                    <input class="type-file-file" onClick="GetUploadify(1,'','ad','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                </span>
          </div>
          <span class="err"></span>
          <p class="notic">请上传图片格式文件,建议图片尺寸3:2(宽*高, 如果不按要求上传图片将会导致前端广告显示不友好)</p>
        </dd>
      </dl>
      
      <dl class="row">
        <dt class="tit" colspan="2">
          <label>链接类型：</label>
        </dt>
        <dd class="opt">
          <div>
          		<select name="linktype" id="linktype" class="input-sm" class="form-control">
	                <option value="1" <if condition="$info.linktype eq 1">selected</if>>商品</option>
	                <option value="2" <if condition="$info.linktype eq 2">selected</if>>联系我们</option>
	            </select> 
          </div>          
        </dd>
     </dl>
      
      <dl class="row" id='goodspanl'>            	
        <dt class="tit">
            <label><em>*</em>对应商品</label>
        </dt>
        <dd class="opt">
            <div style="overflow: hidden;" id="selected_group_goods">
                <volist name="a_goods" id="goods">
                        <div style="float: left;margin-right: 20px">
                        	<!--goods[0]['goods_id']-->
                            <input type="hidden" name="goodsid" value="{$goods.id}"/>
                            <div class="ys-btn-close" style="top: 15px;left: 172px;">×</div>
                            <div class="selected-group-goods">
                                <div class="goods-thumb"><img style="width: 162px;height: 162px" src="__PUBLICROOT__{$goods['icon']}"/></div>
                                <div class="goods-name">
                                    <p>{$goods.gname}</p>
                                </div>
                                <div class="goods-price">商城价：￥{$goods.price}</div>
                            </div>
                        </div>
                </volist>
            </div>
            <span class="err" id="err_goodsid" style="color:#F00; display:none;">请添加对应商品</span>
            <p class="notic">
                <a onclick="selectGoods()" class="ncap-btn"><i class="fa fa-search"></i>选择商品</a>
            </p>
        </dd>
      </dl>
      
      <div class="bot"><a href="JavaScript:void(0);" onclick="adsubmit()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
    </div>
       <input type="hidden" name="act" value="{$act}">
       <input type="hidden" name="aid" value="{$info.aid}">
  </form>
</div>
 <script>
	 function adsubmit(){
//		$('#handleposition').submit();

			var urls = "{:U('Admin/Ad/adHandle')}";
     	ajax_submit_form('handleposition',urls);
	}
	
	 function select_goods_dialog(){
		 var url = "/index.php?m=Admin&c=ad&a=search_goods";
         layer.open({
             type: 2,
             title: '选择商品',
             shadeClose: true,
             shade: 0.2,
             area: ['1020px', '75%'],
             content: url
         });
	 }
	 
	 

 
  $(document).ready(function(){

	
		 
	});
    
    function call_back(goodsItem){
        var html = '';
        
        $.each(goodsItem, function (index, item) {
        	$('#selected_group_goods').empty();
            if (item.goods_id != 'on') {
                 html += '<div style="float: left;margin-right: 20px"><div class="ys-btn-close" style="top: 15px;left: 172px;">×</div>' +
                            '<input type="hidden" name="goodsid" value="' + item.goods_id + '"/>' +
                            '<div class="selected-group-goods"><div class="goods-thumb">' +
                            '<img style="width: 162px;height: 162px" src="__PUBLICROOT__' + item.icon + '"/></div> <div class="goods-name"> ' +
                            '<p>' + item.goods_name + '</p> </div>' +
                            ' <div class="goods-price">商城价：￥' + item.goods_price + '</div> </div></div>';
            }
        });
        $('#selected_group_goods').append(html);
        layer.closeAll('iframe');
    }
    
     function img_call_back(fileurl_tmp)
     {
       $("#icon").val(fileurl_tmp);
//     $("#img_a").attr('href', fileurl_tmp);
       var showurl = localUrl + fileurl_tmp;
       $("#img_i").attr('onmouseover', "layer.tips('<img src="+ showurl+">',this,{tips: [1, '#fff']});");
     }
     
     var ltype = "{$info.linktype}";
		 lint_type_show(ltype);//如果是编辑
     
     $("#linktype").on("change",function(){ 
			 var linktype = $('#linktype option:selected').val();
			 lint_type_show(linktype);
		 });
		 
		 function lint_type_show(linktype){
		 	if(linktype==1){
			 	$('#goodspanl').show();
			 }
			 else{
			 	$('#goodspanl').hide();
			 }
		 }
		 
     
    function selectGoods(){
				var url = "{:U('Ad/search_goods',array('goods_id'=>$info.id))}";
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.3,
            area: ['70%', '80%'],
            content: url,
        });
    }
 </script>
</body>
</html>